package cn.smartorigin.soas.frame.panel;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

import cn.smartorigin.soas.frame.ImageButton;

public abstract class Portlet extends JPanel{
	
    private boolean running = true;
    private static JFileChooser chooser;
    
    ImageIcon minimizeIcon = new ImageIcon("res/images/minimize.png");
    ImageIcon minimizeIcon_p = new ImageIcon("res/images/minimize_p.png");
    //private AbstractChart chart;
    
//    public void initialize(){
        //JToolBar toolbar = getControlPanel();
        //this.setLayout(new BorderLayout());
        //this.add(toolbar, BorderLayout.NORTH);
//    }
    
//    public AbstractChart getChart() {
//        return chart;
//    }
    
    abstract public ImageButton getImageButton();
    abstract public void showMode(boolean isFullscreen);
    
    public JToolBar getControlPanel(){
        JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);
        //toolbar.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
        toolbar.setLayout(new BorderLayout());
        toolbar.setRollover(true);
        toolbar.setFloatable(false);

        
        //JButton fullScreen = createButton("/resource/image/network/fullScreen.png");
        ImageButton fullScreen = new ImageButton(minimizeIcon, minimizeIcon, minimizeIcon_p);
        fullScreen.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                PortletPanel container = (PortletPanel) Portlet.this.getParent().getParent();
                container.fullScreen(Portlet.this);
            }
        });
        toolbar.add(fullScreen, BorderLayout.EAST);


        return toolbar;
    }

}
